%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/v4/connections-totalCount"
    Bucket0("Bucket 0 (root)<br /><br />1: PgSelectInlineApply[51]<br />ᐳ: 9, 10, 42, 49, 11<br />2: PgSelect[8], PgSelect[22], PgSelect[30]<br />ᐳ: Access[52]<br />3: 17, 24, 32<br />ᐳ: 23, 25, 26, 31, 33, 34<br />4: ConnectionItems[27]"):::bucket
    Bucket1("Bucket 1 (nullableBoundary)<br />Deps: 49, 26<br /><br />ROOT Constantᐸ[HIDDEN]ᐳ[49]"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 17, 27, 52, 49<br /><br />ROOT Connectionᐸ8ᐳ[17]"):::bucket
    Bucket3("Bucket 3 (nullableBoundary)<br />Deps: 49, 34<br /><br />ROOT Constantᐸ[HIDDEN]ᐳ[49]"):::bucket
    Bucket5("Bucket 5 (listItem)<br />Deps: 52, 49<br /><br />ROOT __Item{5}ᐸ27ᐳ[35]"):::bucket
    Bucket6("Bucket 6 (nullableBoundary)<br />Deps: 52, 35, 36, 49<br /><br />ROOT PgSelectSingle{5}ᐸpersonᐳ[36]<br />1: <br />ᐳ: List[53], Lambda[54]<br />2: PgSelectRows[46]<br />ᐳ: 45, 47, 48"):::bucket
    end
    Bucket0 --> Bucket1 & Bucket2 & Bucket3
    Bucket2 --> Bucket5
    Bucket5 --> Bucket6

    %% plan dependencies
    PgSelect8[["PgSelect[8∈0] ➊<br />ᐸpersonᐳ"]]:::plan
    Object11{{"Object[11∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    PgFromExpression42{{"PgFromExpression[42∈0] ➊"}}:::plan
    PgSelectInlineApply51["PgSelectInlineApply[51∈0] ➊"]:::plan
    Object11 & PgFromExpression42 & PgSelectInlineApply51 --> PgSelect8
    Access9{{"Access[9∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access10{{"Access[10∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access9 & Access10 --> Object11
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access9
    __Value2 --> Access10
    Connection17[["Connection[17∈0] ➊<br />ᐸ8ᐳ"]]:::plan
    PgSelect8 --> Connection17
    PgSelect22[["PgSelect[22∈0] ➊<br />ᐸperson(aggregate)ᐳ"]]:::plan
    Object11 --> PgSelect22
    First23{{"First[23∈0] ➊"}}:::plan
    PgSelectRows24[["PgSelectRows[24∈0] ➊"]]:::plan
    PgSelectRows24 --> First23
    PgSelect22 --> PgSelectRows24
    PgSelectSingle25{{"PgSelectSingle[25∈0] ➊<br />ᐸpersonᐳ"}}:::plan
    First23 --> PgSelectSingle25
    ConnectionItems27[["ConnectionItems[27∈0] ➊"]]:::plan
    Connection17 --> ConnectionItems27
    PgSelect30[["PgSelect[30∈0] ➊<br />ᐸtable_set_query(aggregate)ᐳ"]]:::plan
    Object11 --> PgSelect30
    First31{{"First[31∈0] ➊"}}:::plan
    PgSelectRows32[["PgSelectRows[32∈0] ➊"]]:::plan
    PgSelectRows32 --> First31
    PgSelect30 --> PgSelectRows32
    PgSelectSingle33{{"PgSelectSingle[33∈0] ➊<br />ᐸtable_set_queryᐳ"}}:::plan
    First31 --> PgSelectSingle33
    Access52{{"Access[52∈0] ➊<br />ᐸ8.m.subqueryDetailsFor44ᐳ"}}:::plan
    PgSelect8 --> Access52
    __Item35[/"__Item[35∈5]<br />ᐸ27ᐳ"\]:::itemplan
    ConnectionItems27 ==> __Item35
    PgSelectSingle36{{"PgSelectSingle[36∈5]<br />ᐸpersonᐳ"}}:::plan
    __Item35 --> PgSelectSingle36
    List53{{"List[53∈6]<br />ᐸ52,35ᐳ"}}:::plan
    Access52 & __Item35 --> List53
    First45{{"First[45∈6]"}}:::plan
    PgSelectRows46[["PgSelectRows[46∈6]"]]:::plan
    PgSelectRows46 --> First45
    Lambda54{{"Lambda[54∈6]<br />ᐸpgInlineViaSubqueryTransformᐳ"}}:::plan
    Lambda54 --> PgSelectRows46
    PgSelectSingle47{{"PgSelectSingle[47∈6]<br />ᐸperson_friendsᐳ"}}:::plan
    First45 --> PgSelectSingle47
    PgClassExpression48{{"PgClassExpression[48∈6]<br />ᐸcount(*)ᐳ"}}:::plan
    PgSelectSingle47 --> PgClassExpression48
    List53 --> Lambda54

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect8,Access9,Access10,Object11,Connection17,PgSelect22,First23,PgSelectRows24,PgSelectSingle25,ConnectionItems27,PgSelect30,First31,PgSelectRows32,PgSelectSingle33,PgFromExpression42,PgSelectInlineApply51,Access52 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3 bucket3
    classDef bucket5 stroke:#7fff00
    class Bucket5,__Item35,PgSelectSingle36 bucket5
    classDef bucket6 stroke:#ff1493
    class Bucket6,First45,PgSelectRows46,PgSelectSingle47,PgClassExpression48,List53,Lambda54 bucket6

